package com.person.tbsystem.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import com.person.tbsystem.R;
import com.person.tbsystem.globarVar.TbConstants;
import com.person.tbsystem.utlis.SharedPreferencesUtils;

/**
 * Created by Demon on 2015/12/28.
 */
public class SplashActivity extends Activity {
    private final int SPLASH_DISPLAY_LENGHT = 3000; //延迟三秒
    boolean mFirst_open = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        mFirst_open = (Boolean) SharedPreferencesUtils.getParam(SplashActivity.this, TbConstants.FIRST_OPEN, false);
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                if (mFirst_open) {
                    Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
                    SplashActivity.this.startActivity(mainIntent);
                    SplashActivity.this.finish();
                }else{
                    Intent guideIntent = new Intent(SplashActivity.this, GuideActivity.class);
                    SplashActivity.this.startActivity(guideIntent);
                    SplashActivity.this.finish();
                }
            }

        }, SPLASH_DISPLAY_LENGHT);
    }
}
